<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Customer</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="" lay-filter="table-search">
                    <div class="layui-form-item">
                       <!-- <div class="layui-inline">
                            <label class="layui-form-label">名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" autocomplete="off" class="layui-input">
                            </div>
                        </div>-->
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <div style="margin:10px;">
            <button type="button" class="layui-btn" id="upload-boss-list" title="BOSS一览专题页.xlsx">
                <i class="layui-icon layui-icon-upload"></i> boss数据导入
            </button>
        </div>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>
</body>
</html>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/common.js?v=5" charset="utf-8"></script>
<script type="text/html" id="currentTableBar">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit">上传图片</a>
</script>
<script>
    layui.use(['upload','form','table'],function () {
        var upload = layui.upload,$=layui.$,table=layui.table,form=layui.form;
        var excelMime = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
        upload.render({
            elem: '#upload-boss-list',
            data:{name:"BOSS一览专题页.xlsx"},
            auto:true,
            accept:'file',
            exts:"xlsx",
            acceptMime:excelMime,
            url:"/admin/boss/import",
            done:function(res){
                if (res.code !==0 ){
                    layer.msg(res.msg,{icon:2})
                } else {
                    layer.msg('导入成功',{icon:1})
                }
            }
        });

        table.render({
            where: form.val('table-search'),
            elem: '#currentTableId',
            url: '/admin/boss/paginate',
            defaultToolbar: ['filter','print'],
            toolbar: '#toolbarDemo',
            cols: [[
                {title: '操作', minWidth: 100, toolbar: '#currentTableBar', align: "center"},
                {field:"name",title:'Boss名称',width:110},
                {field:"map",title:"地图",width:110},
                {field:"level",title:"等级" ,width:110},
                {field:"blood",title:"血量" ,width:110},
                {field:"attack",title:"攻击",width:110 },
                {field:"attack",title:"攻击" ,width:110},
                {field:"hit_rate",title:"命中率",width:110 },
                {field:"dodge",title:"闪避" ,width:110},
                {field:"wk",title:"物抗",width:110 },
                {field:"fk_ice",title:"法攻(冰)",width:110 },
                {field:"fk_fire",title:"法攻(火)" ,width:110},
                {field:"fk_electricity",title:"法攻(电)",width:110 },
                {field:"fk_noxious",title:"法攻(毒)",width:110 },
                {field:"drop_item",title:"掉落物品",width:110 },
                {field:"description",title:"描述" ,width:110}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            skin: 'line'
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: form.val('table-search')
            }, 'data');
            return false;
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event==='edit'){
                layer.open({
                    type: 2, // page 层类型
                    area: ['780px', '600px'],
                    title: '编辑',
                    shade: 0.6, // 遮罩透明度
                    shadeClose: true,
                    maxmin: true, // 允许全屏最小化
                    content: "bossEdit.html?id="+data.id
                });
            }
        });

    })
</script>